package network;

import java.security.PrivateKey;
import java.security.PublicKey;

import core.Phrox;
import encryption.KeyReader;
import encryption.KeyRing;


/**
 * This class holds information for the program.
 * @author Gianni Gambetti
 */
public class NetworkVars {

	//Things that should be moved at a later date
	public static KeyReader keyRead = new KeyReader();
	public static KeyRing keyRing = new KeyRing(Phrox.rootDir+"res"+Phrox.fD+"index.keys"); 
	public static PublicKey pubKey = null;
	public static PrivateKey prvKey = null;
	
	
	
	
	
	//this class holds information like which socket to use ect.
	
	public static boolean showData=false;
	public static boolean debug=false;
	
	//public static int socketNum=54444;//port to connect to. 
	/**
	 *Used in connection protocol to determine if we're talking to the right application.
	 *@see network.NetworkingProtocol Networking Protocol for more info. 
	 * */
	public static String name = core.Phrox.name.toUpperCase()+"_"+core.Phrox.version;
	
	/**
	 * Nick name used by phrox, on servers it defaults to "SERVER" only clients can change their names
	 */
	public static User localUsr = new User(System.getProperty("user.name"),"127.0.0.1");
	
	//retrying things that have failed
	public static byte MAX_RETRY = 3;
	
	//Server
	public static int MAX_CONNECTIONS = 10;
	
	public static boolean watchData = false;//watch things like keepalives, and print out their contents. Just in case there is something in them.
	
	public static String encryption = null;//this is the encryption type we're using.
	
	//======================FINAL
	//file transfer, file transfer stuff not in use
	public static final int fileChunk = 512;//file chunk size in bytes
	public static final String encode = "SHA-512";//hash algorithm
	
	//other stuff
	public static final String Msg_Format = "";//to change special formatting before special messages,
	
	public static final int inetLen = 4;//for ip v4 or v6, byte length. v4=4, v6=16
	public static final int defTTL = 2;//default time to live for multicast packets.
									//This should keep the packets within a relatively small scope
	
	public static final String workingDir = System.getProperty("user.dir");
	
	// such as enter/exit messages
	public static final int broadcastPort = 54444;//port to listen to for broadcast messages
	public static final String broadcastIP = "228.5.6.7";
	
	public static final int bufSize = 1024;//size of the buffers for reading + writing //overkill?
	public static final int defSleep = 100;//100ms is default sleep time.
	public static final int longSleep = 1000;//default sleep for things that happen far between...
	public static final long connection_Timeout = 1000*60;//1 minute
	public static final long lag_Timeout = 1000*15;//this is for keep alive sending, every 15 seconds.
}
